package com.jike.shop.cloud.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 *
 */
@Getter
@AllArgsConstructor
public enum OrderPayMethodEnum {

    JD("JD", "京东支付", true),
    WX("WX", "微信支付", false),
    CARD("CARD", "银行卡支付", false);

    /**
     * 订单状态
     */
    @EnumValue
    private String code;
    /**
     * 订单状态描述
     */
    private String desc;

    /**
     * 是否同步支付
     */
    private boolean syncPay;

    public static OrderPayMethodEnum getTarget(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        OrderPayMethodEnum[] values = OrderPayMethodEnum.values();
        for (OrderPayMethodEnum e : values) {
            if (StringUtils.equals(code, e.code)) {
                return e;
            }
        }
        return null;
    }
}
